package me.heshang.rednamedrop;

import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.inventory.*;
import java.util.Random;
public class DropItem implements Listener {
    public static int Count;
    public static int RedCount = 2;
    public void DropItem(Player p) {
        for (int i=0;i<Count;i++) {
            int slot = new Random().nextInt(45)+5;
            ItemStack itemStack = p.getInventory().getItem(slot);
            if (itemStack != null) {
                Location loc = p.getLocation();
                loc.getWorld().dropItem(loc, itemStack);
                p.getInventory().setItem(slot, null);
            }
        }
    }
    public void RedDropItem(Player p){
        for (int i=0;i<RedCount;i++) {
            int slot = new Random().nextInt(46)+5;
            ItemStack itemStack = p.getInventory().getItem(slot);
            if (itemStack != null) {
                Location loc = p.getLocation();
                loc.getWorld().dropItem(loc, itemStack);
                p.getInventory().setItem(slot, null);
            }
        }
    }
}
